package liportest.ability;


import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@AllArgsConstructor
@Slf4j
@RestController()
@RequestMapping("ability")
public class AbilityController {
    final AbilityServiceImpl abilityService;

    @GetMapping("/all")
    public String getOrders() {
        return abilityService.getAbility().toString();
    }

    @GetMapping("/create")
    public String createAbility() {
        log.info("Create Ability");
        final AbilityModel ability = abilityService.createAbility();
        return ability.toString();
    }

    @GetMapping("/pass/{id}")
    public String passAbility(@PathVariable int id) {
        final AbilityModel ability = abilityService.submitApproveAbility(id);
        return ability.toString();
    }


        public static void main(String[] args) {
            BigDecimal a = new BigDecimal("10");
            BigDecimal b = new BigDecimal("5");
            BigDecimal c = new BigDecimal("2");

            // 表达式：a + b * c
            BigDecimal result1 = a.add(b.multiply(c));
            System.out.println("a + b * c = " + result1); // 输出：20

            // 表达式：(a + b) * c
            BigDecimal result2 = a.add(b).multiply(c);
            System.out.println("(a + b) * c = " + result2); // 输出：30

            // 表达式：a / b + c
            BigDecimal result3 = a.divide(b, BigDecimal.ROUND_HALF_UP).add(c);
            System.out.println("a / b + c = " + result3); // 输出：4

            // 表达式：a - b / c
            BigDecimal result4 = a.subtract(b.divide(c, BigDecimal.ROUND_HALF_UP));
            System.out.println("a - b / c = " + result4); // 输出：8
        }


}
